/**
 * 功能描述
 */

define(function (require, exports, module) {
	var Subnav = require("subnav");
//	var transfernotes = require("./store/transfernotes");
	var aw = require("ajaxwrapper");
    var instance = {
        initComponent: function (params,widget) {
        	
        	var subnav = new Subnav({
        		parentNode:".J-subnav",
        		model:{
        			title:"转让记录",
        			items:[{
        				id:"search",
        				type:"search",
        				placeholder:"当前持证人/合同号",
        				handler:function(str){
        					var grid = widget.get("grid");
        					var subnav = widget.get("subnav");
        					aw.ajax({
        						url:"api/certificatestransfer/search",
        						data:{
        							s:str,
        							searchProperties:"travelContract.memberCertificates,travelContract.contactNo",//查询条件（持证人/合同号）
        							fetchProperties:"*,travelContract.*,travelContract.member.personalInfo.*,travelContract.productRule.product.*,travelContract.productType.*",
        						},
        					dataType:"json",
    						success:function(data){
    							grid.setData(data);
    						}
        					})
        				}
        			},{
        				id:"operateDate",
        				tip:"转让时间查询",
						type:"daterange",
						ranges : {
							"今天": [moment().startOf("days"),moment().endOf("days")],
					        "本月": [moment().startOf("month"), moment().endOf("month")],
					        "本年": [moment().startOf("year"), moment().endOf("days")]
						},
						defaultRange : "本年",
						handler : function(time){
							 widget.get("grid").refresh();
						}
        			},{
						id : "return",
						type : "button",
						text : "返回",
						show : false,
						handler : function(){
							widget.hide([".J-grid-show"]).show(".J-grid");
							widget.get("subnav").hide(["return"]).show(["search","operateDate"]);
							widget.get("grid").refresh();
						}
					}]
        		}
        	})
        	widget.set("subnav",subnav);
        }
    };
    module.exports = instance;
});
